<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Deploying to Microsoft Azure Cloud</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/deploying-to-azure-cloud" />
  <meta property="og:title" content="Quarkus - Deploying to Microsoft Azure Cloud" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/deploying-to-azure-cloud">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Deploying to Microsoft Azure Cloud</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#change-quarkus-http-port">Change Quarkus HTTP Port</a></li>
<li><a href="#install-the-azure-cli">Install the Azure CLI</a></li>
<li><a href="#create-an-azure-container-registry-instance">Create an Azure Container Registry instance</a></li>
<li><a href="#upload-container-image-on-azure">Upload Container Image on Azure</a></li>
<li><a href="#deploy-to-azure-container-instances">Deploy to Azure Container Instances</a></li>
<li><a href="#deploy-to-azure-kubernetes-service">Deploy to Azure Kubernetes Service</a></li>
<li><a href="#deploy-to-azure-app-service-on-linux-containers">Deploy to Azure App Service on Linux Containers</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>This guide covers:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Update Quarkus HTTP Port</p>
</li>
<li>
<p>Install the Azure CLI</p>
</li>
<li>
<p>Create an Azure Registry Service instance and upload the Docker image</p>
</li>
<li>
<p>Deploy the Docker image to Azure Container Instances</p>
</li>
<li>
<p>Deploy the Docker image to Azure Kubernetes Service</p>
</li>
<li>
<p>Deploy the Docker image to Azure App Service for Linux Containers</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="prerequisites"><a class="anchor" href="#prerequisites"></a>Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For this guide you need:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>roughly 2 hours for all modalities</p>
</li>
<li>
<p>having access to an Azure subscription. <a href="https://azure.microsoft.com/free/?WT.mc_id=opensource-quarkus-brborges">Get a free one here</a></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This guide will take as input a native application developed in the <a href="building-native-image">building native image guide</a>.</p>
</div>
<div class="paragraph">
<p>Make sure you have the getting-started application at hand, or clone the Git repository: <code>git clone <a href="https://github.com/quarkusio/quarkus-quickstarts.git" class="bare">https://github.com/quarkusio/quarkus-quickstarts.git</a></code>, or download an <a href="https://github.com/quarkusio/quarkus-quickstarts/archive/master.zip">archive</a>. The solution is located in the <code>getting-started</code> directory.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="change-quarkus-http-port"><a class="anchor" href="#change-quarkus-http-port"></a>Change Quarkus HTTP Port</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you correctly followed the <a href="building-native-image">building native image guide</a>, you should have a local container image named <code>quarkus-quickstart/getting-started</code>.</p>
</div>
<div class="paragraph">
<p>While Quarkus by default runs on port 8080, most Azure services expect web applications to be running on port 80. Before we continue, go back to your quickstart code and open the file <code>src/main/docker/Dockerfile.native</code>.</p>
</div>
<div class="paragraph">
<p>Change the last two commands in the <code>Dockerfile.native</code> file and make it read like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="docker" class="language-docker hljs">EXPOSE 80
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=80"]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can rebuild the docker image:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ docker build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started .</code></pre>
</div>
</div>
<div class="paragraph">
<p>To test, run it by exposing port 80 into port 8080 in your host:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ docker run -i --rm -p 8080:80 quarkus-quickstart/getting-started</code></pre>
</div>
</div>
<div class="paragraph">
<p>Your container image is now ready to run on Azure. Remember, the Quarkus application is mapped to run on port 80.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="install-the-azure-cli"><a class="anchor" href="#install-the-azure-cli"></a>Install the Azure CLI</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To ease the user experience throughout this guide, it is better to have the Azure CLI installed and authenticated.</p>
</div>
<div class="paragraph">
<p>Visit the <a href="https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest?WT.mc_id=opensource-quarkus-brborges">Azure CLI</a> installation page for instructions specific to your operating system.</p>
</div>
<div class="paragraph">
<p>Once installed, ensure you are authenticated:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az login</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="create-an-azure-container-registry-instance"><a class="anchor" href="#create-an-azure-container-registry-instance"></a>Create an Azure Container Registry instance</h2>
<div class="sectionbody">
<div class="paragraph">
<p>It is possible to deploy images hosted on Docker Hub, but this location by default leaves images accessible to anyone. To better protect your container images, this guide shows how to host your images on a private instance of the Azure Container Registry service.</p>
</div>
<div class="paragraph">
<p>First, create an Azure Resource Group:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az group create --name &lt;resource-group-name&gt; --location eastus</code></pre>
</div>
</div>
<div class="paragraph">
<p>Then you can create the ACR:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az acr create --resource-group &lt;resource-group-name&gt; --name &lt;registry-name&gt; --sku Basic --admin-enabled true</code></pre>
</div>
</div>
<div class="paragraph">
<p>Finally, authenticate your local Docker installation with this container registry by running:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az acr login --name &lt;registry-name&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="upload-container-image-on-azure"><a class="anchor" href="#upload-container-image-on-azure"></a>Upload Container Image on Azure</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you&#8217;ve followed the build native image guide, you should have a local container image named <code>quarkus-quickstart/getting-started</code>.</p>
</div>
<div class="paragraph">
<p>To upload this image to your ACR, you must tag and push the image under the ACR login server. To find the login server of the Azure Container Registry, run this command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az acr show -n &lt;registry-name&gt; --query loginServer</code></pre>
</div>
</div>
<div class="paragraph">
<p>To upload, now do:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ docker tag quarkus-quickstart/getting-started &lt;acr-login-server&gt;/quarkus-quickstart/getting-started
$ docker push &lt;acr-login-server&gt;/quarkus-quickstart/getting-started</code></pre>
</div>
</div>
<div class="paragraph">
<p>At this point, you should have your Quarkus container image on your Azure Container Registry. To verify, run the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az acr repository list -n &lt;registry-name&gt;</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="deploy-to-azure-container-instances"><a class="anchor" href="#deploy-to-azure-container-instances"></a>Deploy to Azure Container Instances</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The simplest way to start this container in the cloud is with the Azure Container Instances service. It simply creates a container on Azure infrastructure.</p>
</div>
<div class="paragraph">
<p>There are different approaches for using ACI. Check the documentation for details. The quickest way to get a container up and running goes as it follows.</p>
</div>
<div class="paragraph">
<p>First step is to find the username and password for the admin, so that ACI can authenticate into ACR and pull the Docker image:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az acr credential show --name &lt;registry-name&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now create the Docker instance on ACI pointing to your image on ACR:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">$ az container create \
    --name quarkus-hello \
    --resource-group &lt;resource-group&gt; \
    --image &lt;acr-login-server&gt;/quarkus-quickstart/getting-started \
    --registry-login-server &lt;acr-login-server&gt; \
    --registry-username &lt;acr-username&gt; \
    --registry-password &lt;acr-password&gt; \
    --dns-name-label quarkus-hello-&lt;random-number&gt; \
    --query ipAddress.fqdn</code></pre>
</div>
</div>
<div class="paragraph">
<p>The command above, if run successfully, will give you the address of your container in the Cloud. Access your Quarkus application in the address displayed as output.</p>
</div>
<div class="paragraph">
<p>For more information and details on ACR authentication and the use of service principals, follow this guide below and remember the Azure Container Registry <code>loginServer</code> and the image name of your Quarkus application now hosted on the ACR.</p>
</div>
<div class="paragraph">
<p><a href="https://docs.microsoft.com/en-us/azure/container-instances/container-instances-using-azure-container-registry?WT.mc_id=opensource-quarkus-brborges">Deploy to Azure Container Instances from Azure Container Registry</a></p>
</div>
<div class="paragraph">
<p>Keep in mind that this service does not provide scalability. A container instance is unique and does not scale.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="deploy-to-azure-kubernetes-service"><a class="anchor" href="#deploy-to-azure-kubernetes-service"></a>Deploy to Azure Kubernetes Service</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You can also deploy the container image as a microservice in a Kubernetes cluster on Azure. To do that, follow this tutorial:</p>
</div>
<div class="paragraph">
<p><a href="https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-cluster?WT.mc_id=opensource-quarkus-brborges">Tutorial: Deploy an Azure Kubernetes Service (AKS) cluster</a></p>
</div>
<div class="paragraph">
<p>Once deployed, the application will be running on whatever port is used to expose the service. By default, Quarkus apps run on port 8080 internally.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="deploy-to-azure-app-service-on-linux-containers"><a class="anchor" href="#deploy-to-azure-app-service-on-linux-containers"></a>Deploy to Azure App Service on Linux Containers</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This service provides scalability out of the box for web applications. If more instances are required, it will provide a load-balancing automatically, plus monitoring, metrics, logging and so on.</p>
</div>
<div class="paragraph">
<p>To deploy your Quarkus Native container image to this service, follow this tutorial:</p>
</div>
<div class="paragraph">
<p><a href="https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image?WT.mc_id=opensource-quarkus-brborges">Tutorial: Build a custom image and run in App Service from a private registry</a></p>
</div>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
